<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/style/admin.css">
    <link rel="stylesheet" href="/static/admin/style/login.css">
    <link href="/static/admin/css/jquery.slider.css" rel="stylesheet">
    <script src="/static/admin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
    .layadmin-user-login {
        background: url('{$background}') !important;
        background-size: cover !important;
        color: #999 !important;
    }
    .layui-form-checkbox[lay-skin=primary] span{
        color: white !important;
    }
</style>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main"  style="background: rgba(255,255,255,.2);border: 1px solid rgba(255,255,255,.3);border-radius: 3px;">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>oAdmin</h2>
            <p style="color: white">安玛尔办公系统</p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <input type="hidden" name="__token__" value="{:token()}" />
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                       for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
                       placeholder="密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                {if condition="$verify_type eq 1"}
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
                               for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required"
                               placeholder="图形验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="{:captcha_src()}" class="layadmin-user-login-codeimg"
                                 style="float:right;cursor: pointer" alt="captcha"
                                 id="LAY-user-get-vercode"
                                 onclick="javascript:this.src='{:captcha_src()}?tm='+Math.random();">
                        </div>
                    </div>
                </div>
                {else}
                <div class="layui-row">
                    <div id="slider" class="slider"></div>
                </div>
                {/if}
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
<!--                <input type="checkbox" name="remember" lay-skin="primary" title="记住密码" >-->
                <input type="checkbox" name="keeplogin" lay-skin="primary" id="keeplogin" value="1" title="保持回话"  />
<!--                <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>记住密码</span><i-->
<!--                        class="layui-icon layui-icon-ok"></i></div>-->
                <a lay-href="/user/forget" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px; color:white;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" id="dologin" lay-submit="" lay-filter="LAY-user-login-submit">
                    登 入
                </button>
            </div>
            <!--            <div class="layui-trans layui-form-item layadmin-user-login-other">-->
            <!--                <label>社交账号登入</label>-->
            <!--                <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>-->
            <!--                <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>-->
            <!--                <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>-->

            <!--                <a lay-href="/user/reg" class="layadmin-user-jump-change layadmin-link">注册帐号</a>-->
            <!--            </div>-->
        </div>
    </div>
    <div class="layui-trans layadmin-user-login-footer" style="color: white;">
        <p>© 2019 <a href="#" style="color: white;" target="_blank">admin</a></p>
    </div>
</div>
<script src="/static/admin/video/jquery.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.slider.min.js"></script>
<script>

    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form', 'index', 'jquery'], function () {
        var $ = layui.$
            , form = layui.form;
        //滑块验证
        var check_result = false;
        $("#slider").slider({
            width: 333, // width
            height: 35, // height
            sliderBg: "rgb(232, 232, 232)", // 滑块背景颜色
            color: "rgb(114, 114, 114)", // 文字颜色
            fontSize: 14, // 文字大小
            bgColor: "#1ab394", // 背景颜色
            textMsg: "按住滑块，拖拽验证", // 提示文字
            successMsg: "验证成功", // 验证成功提示文字
            successColor: "#ffffff", // 滑块验证成功提示文字颜色
            time: 400, // 返回时间
            callback: function (result) { // 回调函数，true(成功),false(失败)
                console.log(result);
                check_result = result;
            }
        });
        form.render();
        $(document).keydown(function (e) {
            if (e.keyCode == 13) {
                $("#dologin").click();
            }
        });
        $("#dologin").click(function () {
            form.on('submit(LAY-user-login-submit)', function (obj) {
                if ({$verify_type} == 0) {
                    if (false == check_result) {
                        layer.msg('请拖动滑块到最右边', {icon: 2});
                        return false;
                    }
                }
                $.post(
                    '{:url("admin/login/index")}',
                    obj.field,
                    function (res) {
                        if (res.code == 1) {
                            layer.msg(res.msg, {icon: 1, time: 2000}, function (index) {
                                layer.close(index);
                                window.location.href = res.url;
                            });
                        } else {
                            layer.msg(res.msg, {icon: 2, time: 2000}, function (index) {
                                layer.close(index);
                            });
                            return false;
                        }
                    }
                );
            });
        });

    });


</script>
</body>
</html>